
#ifndef SMARTTRADELOGGER_H
#define SMARTTRADELOGGER_H

#ifdef SMARTTRADELOGGER_EXPORTS
#define SMARTTRADELOGGER_API __declspec(dllexport)
#else
#define SMARTTRADELOGGER_API __declspec(dllimport)
#endif


typedef enum {
	LOG_LEVEL_DEBUG = 20,
	LOG_LEVEL_INFO = 40,
	LOG_LEVEL_NOTICE = 60,
	LOG_LEVEL_WARN = 80,
	LOG_LEVEL_ERROR = 100,
	LOG_LEVEL_FATAL = 120
} log_level; 

#ifndef _MSC_VER
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# if defined __GNUC__ && __GNUC__ >= 2
#  define __func__ __FUNCTION__
# else
#  define __func__ "<unknown>"
# endif
#endif
//By LL
#else
#define __func__ __FUNCTION__
#endif

SMARTTRADELOGGER_API bool log_init(const char* pConfName);

SMARTTRADELOGGER_API void log_logger(const char* pCategory,
	const char* pFile, size_t filelen,
	const char* pFunc, size_t funclen,
	long lLine, int iLevel,
	const char* pInfo, ...);

SMARTTRADELOGGER_API void log_finish();

//SMARTTRADELOGGER_API char* str_concat(const char* pMsg,const char* pMsg1);
//SMARTTRADELOGGER_API char* str_concat(const char* pMsg,const char* pMsg1,const char* pMsg2);
//SMARTTRADELOGGER_API char* str_concat(const char* pMsg,const char* pMsg1,const char* pMsg2,const char* pMsg3);
//SMARTTRADELOGGER_API char* str_concat(const char* pMsg,const char* pMsg1,const char* pMsg2,const char* pMsg3,const char* pMsg4);


#define log_fatal(cat, ...) \
	log_logger(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	LOG_LEVEL_FATAL, __VA_ARGS__)

#define log_error(cat, ...) \
	log_logger(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	LOG_LEVEL_ERROR, __VA_ARGS__)

#define log_warn(cat, ...) \
	log_logger(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	LOG_LEVEL_WARN, __VA_ARGS__)

#define log_notice(cat, ...) \
	log_logger(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	LOG_LEVEL_NOTICE, __VA_ARGS__)

#define log_info(cat, ...) \
	log_logger(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	LOG_LEVEL_INFO, __VA_ARGS__)

#define log_debug(cat, ...) \
	log_logger(cat, __FILE__, sizeof(__FILE__)-1, __func__, sizeof(__func__)-1, __LINE__, \
	LOG_LEVEL_DEBUG, __VA_ARGS__)


#endif // SMARTTRADELOGGER_H